package com.zhuiyun.educations.api.courseprice.mapper;

import com.zhuiyun.educations.api.courseprice.entity.Price;
import com.zhuiyun.educations.common.mapper.BaseMapper;
import com.zhuiyun.educations.util.pageUtil.PageRequest;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName CoursePriceMapper
 * @Description TODO 课程价钱管理
 * @Author ys
 * @Date 2023/6/19 19:28
 **/
public interface CoursePriceMapper extends BaseMapper<Price> {
    /**
     * @Author ys
     * @Description TODO 分页查询
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @Select("<script>SELECT * FROM price p LEFT JOIN course_info c ON p.course_id = c.id where p.del_flag=0 and c.pay_type=1 " +
            "<when test='courseTitle!=&quot;&quot; and courseTitle!=null'>" +
            "and c.course_title like concat('%',#{courseTitle},'%') </when> </script>")
    List<Price> getPrice(PageRequest pageRequest,String courseTitle);
    /**
     * @Author ys
     * @Description TODO 逻辑删除
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @Update("update price set del_flag=1 where id=#{id}")
    int deletePriceById(int id);
    /**
     * @Author ys
     * @Description TODO 课程动态下拉
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @Select("SELECT * FROM  course c LEFT JOIN image_file i ON c.image_id = i.id where c.del_flag=0")
    List<Price> courseSelect();

    /**
    * @Author 杨友朋
    * @Description 单查价钱
    * @Date 2023/6/27 9:24
    * @Return Price
    * @param id
    */
    @Select("select * from price where id=#{id}")
    Price selectById(Integer id);
}
